package org.darcy.controller.admin.site;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.darcy.entity.SysLog;
import org.darcy.framework.model.PageResult;
import org.darcy.framework.util.ResultUtil;
import org.darcy.model.SysLogModel;
import org.darcy.service.SysLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import cn.hutool.core.util.StrUtil;

/**
 * 系统日志
 */
@RestController
@RequestMapping("/logs")
public class LogController {

	@Autowired
	private SysLogService SysLogService;

	@RequiresPermissions("logs")
	@PostMapping("/list")
	public PageResult list(SysLogModel param) {
		Page p = new Page(param.getP(), param.getPageSize());
		QueryWrapper<SysLog> q = new QueryWrapper<SysLog>();
		if (StrUtil.isNotEmpty(param.getContent()))
			q.like("content", param.getContent());
		IPage pageInfo = SysLogService.getPage(p, q);
		return ResultUtil.tablePage(pageInfo);
	}

}
